package com.szxy.common.redis.service.impl;

import com.szxy.common.redis.service.ItemCatRedisService;
import com.szxy.utils.CatResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Auther:zwer
 * @Date:2019/9/11 11:24
 * @Description:com.szxy.common.redis.service.impl
 * @Version:1.0
 **/
@Service
public class ItemCatRedisServiceImpl implements ItemCatRedisService {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Value("${REDIS_FRONT_CATRESULT_KEY}")
    private String REDIS_FRONT_CATRESULT_KEY;

    @Override
    public void insertItemCatResult(CatResult result) {
        this.redisTemplate.opsForValue().set(this.REDIS_FRONT_CATRESULT_KEY,result);
    }

    @Override
    public CatResult getItemCatResult() {
        return (CatResult) this.redisTemplate.opsForValue().get(this.REDIS_FRONT_CATRESULT_KEY);
    }
}
